<template>
	<view class="container">
		<view class="login">
			<view style="width:100%;text-align: center;font-weight: bold;margin-bottom: 30rpx;">
				模剪积分管理
			</view>
			<view class="login-item">
				<image src="../../static/zhanghao.png" class="logo"></image>
				<input v-model="phone" placeholder="请输入手机号" class="input-val" />
			</view>
			<view class="login-item">
				<image src="../../static/password.png" class="logo"></image>
				<input v-model="password" type="password" placeholder="请输入密码" class="input-val" />
			</view>
			<view class="login-btn" @click="login">
				登录
			</view>
		</view>
		
				
	</view>
</template>

<script>
	import Http from '../../utils/http';
	const http = new Http()
	export default {
		data() {
			return {
				phone: "",
				password: ""
			}
		},
		methods: {
			login() {
				console.log("phone=>", this.phone);
				console.log("password=>", this.password);
				if (!this.phone || this.phone.length < 11) {
					return uni.showToast({
						title: "请输入11位手机号1",
						icon: "error"
					})
				}

				if (!this.password) {
					return uni.showToast({
						title: "请输入密码",
						icon: "error"
					})
				}
				http.post("admin/agentShop/login", {password:this.password,phone:this.phone}).then(res => {
					console.log("登录=》", res);
					if (res.data.code != 200) {
						return uni.showToast({
							title: res.data.msg,
							icon: "none"
						})
					}
					uni.setStorageSync("token",res.data.data)
					uni.switchTab({
						url:"/pages/index/index"
					})
				})


			}
		}
	}
</script>

<style scoped lang="scss">
	page {}

	.container {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		padding-top: 160rpx;

		.login {
			width: 90%;

			.login-item {
				display: flex;
				align-items: center;
				padding: 0 30rpx;
				background: #f9f9f9;
				height: 90rpx;
				margin-bottom: 40rpx;
				border-radius: 45rpx;

				.logo {
					width: 40rpx;
					height: 40rpx;
				}

				.input-val {
					font-size: 32rpx;
					margin-left: 30rpx;
					color: #333
				}
			}

			.login-btn {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				background: orangered;
				color: #fff;
				border-radius: 40rpx;
			}
		}
	}
	
	
</style>